package com.serviceprovider.business.module.sp.transaction.model;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.report.valueobjects.BatchVO;

//~--- JDK imports ------------------------------------------------------------

import java.util.Date;
import java.util.List;

/**
 * @author mrduongnv@gmail.com
 *
 */
public class Batch {
    private Date    batchDate;
    private String  customLabelName1;
    private String  customLabelName2;
    private Integer id;
    private Integer orderId;

    /**
     * Lazy attribute
     */
    private List<TransactionDetail> transactionDetails;

    public Batch() {}

    public Batch(BatchVO batchVO) {
        id               = batchVO.getId();
        customLabelName1 = batchVO.getCustomLabel1Name();
        customLabelName2 = batchVO.getCustomLabel2Name();
        batchDate        = batchVO.getBatchDate();
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setCustomLabelName1(String customLabelName1) {
        this.customLabelName1 = customLabelName1;
    }

    public String getCustomLabelName1() {
        return customLabelName1;
    }

    public void setCustomLabelName2(String customLabelName2) {
        this.customLabelName2 = customLabelName2;
    }

    public String getCustomLabelName2() {
        return customLabelName2;
    }

    public void setBatchDate(Date batchDate) {
        this.batchDate = batchDate;
    }

    public Date getBatchDate() {
        return batchDate;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public List<TransactionDetail> getTransactionDetails() {
        return transactionDetails;
    }

    public void setTransactionDetails(List<TransactionDetail> transactionDetails) {
        this.transactionDetails = transactionDetails;
    }

    @Override
    public boolean equals(Object obj) {
        if ((obj == null) ||!(obj instanceof Batch)) {
            return false;
        }

        Batch   b      = (Batch) obj;
        boolean result = true;

        result &= ((id == null) && (b.id == null)) || ((id != null) && id.equals(b.id));
        result &= ((customLabelName1 == null) && (b.customLabelName1 == null))
                  || ((customLabelName1 != null) && customLabelName1.equals(b.customLabelName1));
        result &= ((customLabelName2 == null) && (b.customLabelName2 == null))
                  || ((customLabelName2 != null) && customLabelName2.equals(b.customLabelName2));
        result &= ((batchDate == null) && (b.batchDate == null))
                  || ((batchDate != null) && batchDate.equals(b.batchDate));
        result &= ((orderId == null) && (b.orderId == null)) || ((orderId != null) && orderId.equals(b.orderId));

        return result;
    }

    @Override
    public int hashCode() {
        int prime  = 31;
        int result = 1;

        result = prime * result + ((id == null)
                                   ? 0
                                   : id.hashCode());
        result = prime * result + ((customLabelName1 == null)
                                   ? 0
                                   : customLabelName1.hashCode());
        result = prime * result + ((customLabelName2 == null)
                                   ? 0
                                   : customLabelName2.hashCode());
        result = prime * result + ((batchDate == null)
                                   ? 0
                                   : batchDate.hashCode());
        result = prime * result + ((orderId == null)
                                   ? 0
                                   : orderId.hashCode());

        return result;
    }
}



